﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DotNet.Common;
/// <summary>
/// basePage 的摘要说明
/// </summary>
public class basePage : System.Web.UI.Page
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        this.Load += new System.EventHandler(basePage_Load);
        this.Error += new System.EventHandler(basePage_Error);
    }
    protected void basePage_Load(object sender, System.EventArgs e)
    {
        if (!IsPostBack)
        {
            if (!DotCookie.Exists("adminUser") || !DotCookie.Exists("adminPwd"))
            {
                Response.Clear();
                JsUtil.LocationNewHref("mainlogin.aspx");
               
                Response.End();
            }
        }
    }
    protected void basePage_Error(object sender, System.EventArgs e)
    {
        string errMsg;
        Exception currentError = Server.GetLastError();
        errMsg = "<link rel=\"stylesheet\" href=\"/style.css\">";
        errMsg += "<h1>系统错误：</h1><hr/>系统发生错误， " +
            "该信息已被系统记录，请稍后重试或与管理员联系。<br/>" +
            "错误地址： " + Request.Url.ToString() + "<br/>" +
            "错误信息： <font class=\"ErrorMessage\">" + currentError.Message.ToString() + "</font><hr/>" +
            "<b>Stack Trace:</b><br/>" + currentError.ToString();
        Response.Write(errMsg);
        Server.ClearError();
    }
}
